class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        unordered_map<string, vector<string>> hash;
        for(const auto& e : strs)
        {
            auto tmp = e;
            sort(tmp.begin(), tmp.end());
            hash[tmp].push_back(e);
        }
        vector<vector<string>> ans;
        ans.reserve(hash.size());
        for(const auto& e : hash) ans.push_back(e.second);
        return ans;
    }
};